<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>机房集群监控</title>
    <meta name="description" content="这是一个 clusterMonitoring 页面">
    <meta name="keywords" content="clusterMonitoring">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/png" href="${ctx}/assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="${ctx}/assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI" />
    <link rel="stylesheet" href="${ctx}/assets/css/amazeui.min.css" />
    <link rel="stylesheet" href="${ctx}/assets/css/admin.css">
    <link rel="stylesheet" href="${ctx}/assets/css/app.css">
    <link rel="stylesheet" href="${ctx}/assets/css/layer.css">
    <link rel="stylesheet" href="${ctx}/assets/css/jquery.treetable.css">
    <link rel="stylesheet" href="${ctx}/assets/css/jquery.treetable.theme.default.css">
    <link rel="stylesheet" type="text/css" href="${ctx}/assets/css/xcConfirm.css"/>
    <style>
        .timeSpan{
            width: 83px;
            display: inline-block;
            font-size: 1.6rem;
        }
        tr.trFocrrus{
            background-color:#eee;
        }
        #prePage3 .am-pagination{
            margin-bottom: 0;
            margin-top: 6px;
        }
    </style>
</head>

<body data-type="chart">
<!--标题-->
<div class="tpl-content-page-title">
 机房集群监控
</div>
<!--面包屑-->
<ol class="am-breadcrumb">
    <li><a href="#" class="am-icon-home">首页</a></li>
    <li><a href="#">监控</a></li>
    <li class="am-active">主机控制</li>
</ol>
<div class="tpl-portlet-components">
    <div class="portlet-title">
        <div class="caption font-green bold">
            主机控制
        </div>
    </div>
    <div class="tpl-block">
        <!--栅格化-->
        <div class="am-g">
            <div class="am-u-sm-12">
                <div>
                    <div class="action">
                        <ul class="actions-btn">
                            <!-- <li class="blue" onclick="batchOrder()">执行命令</li> -->
                            <!-- <li class="blue" onclick="fileTransfer()">文件传输</li>
                             <li class="blue" onclick="softwareDeployment()">软件部署</li> -->
                             <li class="blue" onclick="fileUpload()">文件上传</li>
                             <li class="blue" onclick="fileTransfer()">软件部署/卸载</li>
                            <li class="blue" onclick="setModel()">模式开启/转换</li>
                             <li class="blue" onclick="downMode()">模式关闭</li>
                            <li class="blue" onclick="closeHosts()">批量关机</li>
                        </ul>
                    </div>
                </div>
                <table class="am-table am-table-striped am-table-hover table-main" id="hostList">
                    <thead>
                    <tr>
                        <th style="width: 34px"><input type="checkbox" id="checkAll"></th>
                        <th>分组名</th>
                        <th>主机名字</th>
                        <th>主机IP</th>
                        <th>主机信息</th>
                        <th>当前模式</th>
                        <th>主机操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
                
                <table class="am-table am-table-striped am-table-hover table-main" id="hostList2" style="display:none">
                    <thead>
                    <tr>
                        <th style="width: 34px"><input type="checkbox" id="checkAll"></th>
                        <th>分组名</th>
                        <th>主机名字</th>
                        <th>主机IP</th>
                        <th>主机信息</th>
                        <th>当前模式</th>
                        <th>主机操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
                <hr>
            </div>

        </div>

    </div>

</div>
<script src="${ctx}/assets/js/jQuery/jquery.min.js"></script>
<script src="${ctx}/assets/js/jQuery/jquery-1.9.1.js"></script>
<script src="${ctx}/assets/js/jQuery/jquery.treetable.js"></script>
<script src="${ctx}/assets/js/common/config.js"></script>
<script src="${ctx}/assets/js/common/xcConfirm.js"></script>
<script src="${ctx}/assets/js/common/amazeui.min.js"></script>
<script src="${ctx}/assets/js/common/app.js"></script>
<script src="${ctx}/assets/js/layer/layer.js"></script>
<script src="${ctx}/assets/js/clusterMoniting/hostControl.js"></script>
<script>
    $(function () {
        $.ajax({
            type: "POST",
            url: constUrl+"MonitorHostGroupServlet",
            dataType: "json",
            data: {
                operateType: "showAll"
            },
            success: function (data) {
                let all_data = data.datas;
                for (let i = 0; i < all_data.length; i++){
                    let temp_html = '<tr data-tt-id ="host-group-' + all_data[i].hostGroupId + '"><td><input type="checkbox" id="checkbox_' + all_data[i].hostGroupId + '" onclick="multiCheck(\'' + all_data[i].hostGroupId + '\')"></td><td>' + all_data[i].hostGroupName + '</td><td></td><td></td><td></td><td></td><td></td></tr>'
                    $("#hostList").children("tbody").append(temp_html);
                }

                $("#hostList").treetable({expandable:true});
                $.ajax({
                    type: "POST",
                    url: constUrl+"MonitorHostServlet",
                    dataType: "json",
                    data: {
                        operateType: "showAll"
                    },
                    success: function (data) {
                        let all_data = data.datas;
                        for (let i = 0; i < all_data.length; i++){
                            if (all_data[i].hostGroupIds != ""){
                                let hostGroupList = all_data[i].hostGroupIds.split(',');
                                for (let j = 0; j < hostGroupList.length; j++){
                                    let temp_html = '<tr data-tt-id ="host-' + all_data[i].hostId + '-' + j + '" data-tt-parent-id="host-group-'+hostGroupList[j]+'" >' +
                                        '<td><input type="checkbox" style="margin-left: 18px" value="' + all_data[i].hostId + '" host-parent-group="host-group-' + hostGroupList[j] + '"></td>' +
                                        '<td></td>' +
                                        '<td>'+all_data[i].hostName+'</td>' +
                                        '<td>'+all_data[i].hostIp+'</td>' +
                                        '<td>'+all_data[i].introduction+'</td>' +
                                        '<td>'+all_data[i].modeName+'</td>' +
                                        '<td><ul>'+
                                        /*  '<li style="display:inline"><i class="am-icon-book am-icon-fw" title="远程命令" onclick="telent(\'' + all_data[i].hostIp + '\')"></i></li>' +
                                        '<li style="display:inline"><i class="am-icon-copy am-icon-fw" title="查看进程" onclick="viewInstallers(\'' + all_data[i].hostIp + '\')"></i></li>' +
                                        '<li style="display:inline"><i class="am-icon-file am-icon-fw" title="查看安装程序" onclick="viewProcess(\'' + all_data[i].hostIp + '\')"></i></li>' +
                                        '<li style="display:inline"><i class="am-icon-television am-icon-fw" title="关闭主机" onclick="closeHost(\'' + all_data[i].hostIp + '\')"></i></li>' */  
                                        '<div class=\"am-btn-group am-btn-group-xs \">'+
                                        '<button class=\"am-btn am-btn-default am-btn-xs am-text-success am-hide-sm-only\" onclick="viewInstallers(\'' + all_data[i].hostName + '\')">'+
                                        '<span class=\"am-icon-pencil-square-o\"></span>查看注册进程</button>'+
                                        '<button class=\"am-btn am-btn-default am-btn-xs am-text-primary am-hide-sm-only\" onclick=\"viewProcess(\'' + all_data[i].hostIp + '\')">'+
                                        '<span class=\"am-icon-pencil-square-o\"></span>查看安装程序</button>'+
                                        '<button class=\"am-btn am-btn-default am-btn-xs am-text-success am-hide-sm-only\" onclick=\"checkUsb(\'' + all_data[i].hostIp + '\')">'+
                                        '<span class=\"am-icon-pencil-square-o\"></span>查看USB</button>'+
                                        '<button class=\"am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only\" onclick=\"closeHost(\'' + all_data[i].hostIp + '\')">'+
                                        '<span class=\"am-icon-trash-o\"></span>关机</button></div>'+
                                        '</ul></td></tr>';
                                    let temp_i_parent = $("#hostList").treetable("node", "host-group-"+hostGroupList[j]);
                                    $("#hostList").treetable("loadBranch", temp_i_parent, temp_html);
                                }
                            }
                        }
                    }
                });
            }
        });
    });
</script>
</body>

</html>
